/*
 * Copyright (c) 2005, 2020, Jin Lin All rights reserved.
 * Jin Lin PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 */
package aco.entity.dobject;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述 任务.
 *
 * @author Jin Lin
 * @created 2019 -06-30 13:03:50
 */
public class Task {

    /**
     * 任务的代价.
     */
    private Long value;

    /**
     * 用时间衡量代价.
     */
    private List<Long> costTimes;

    /**
     * 选择不同节点的路径上的信息素浓度.
     */
    private List<Double> pheromoneMatrix;

    /**
     * 信息素浓度的最优值的下标.
     */
    private Integer optimal;

    /**
     * 使用节点速率数组构造任务代价数组.
     *
     * @param value the value
     * @param nodes the nodes
     */
    public Task(Long value, List<Node> nodes) {
        this.value = value;
        List<Long> costTimes = new ArrayList<>();
        for (Node node : nodes) {
            costTimes.add(value / node.getUnitRate());
        }
        this.costTimes = costTimes;
    }

    public Long lengthOfPheromoneMatrix() {
        return Long.parseLong(getPheromoneMatrix().size() + "");
    }


    //============================================================================


    /**
     * Instantiates a new Task.
     */
    public Task() {
    }

    /**
     * Instantiates a new Task.
     *
     * @param value           the value
     * @param costTimes       the cost times
     * @param pheromoneMatrix the pheromone matrix
     * @param optimal         the optimal
     */
    public Task(Long value, List<Long> costTimes, List<Double> pheromoneMatrix, Integer optimal) {
        this.value = value;
        this.costTimes = costTimes;
        this.pheromoneMatrix = pheromoneMatrix;
        this.optimal = optimal;
    }

    /**
     * 描述 Gets value.
     *
     * @return the value
     * @author Jin Lin
     * @created 2019 -06-30 13:36:11
     */
    public Long getValue() {
        return value;
    }

    /**
     * 描述 Sets value.
     *
     * @param value the value
     * @author Jin Lin
     * @created 2019 -06-30 13:36:11
     */
    public void setValue(Long value) {
        this.value = value;
    }

    /**
     * 描述 Gets cost times.
     *
     * @return the cost times
     * @author Jin Lin
     * @created 2019 -06-30 13:36:11
     */
    public List<Long> getCostTimes() {
        return costTimes;
    }

    /**
     * 描述 Sets cost times.
     *
     * @param costTimes the cost times
     * @author Jin Lin
     * @created 2019 -06-30 13:36:11
     */
    public void setCostTimes(List<Long> costTimes) {
        this.costTimes = costTimes;
    }

    /**
     * 描述 Gets pheromone matrix.
     *
     * @return the pheromone matrix
     * @author Jin Lin
     * @created 2019 -06-30 14:12:25
     */
    public List<Double> getPheromoneMatrix() {
        return pheromoneMatrix;
    }

    /**
     * 描述 Sets pheromone matrix.
     *
     * @param pheromoneMatrix the pheromone matrix
     * @author Jin Lin
     * @created 2019 -06-30 14:12:25
     */
    public void setPheromoneMatrix(List<Double> pheromoneMatrix) {
        this.pheromoneMatrix = pheromoneMatrix;
    }

    /**
     * 描述 Gets optimal.
     *
     * @return the optimal
     * @author Jin Lin
     * @created 2019 -06-30 14:12:25
     */
    public Integer getOptimal() {
        return optimal;
    }

    /**
     * 描述 Sets optimal.
     *
     * @param optimal the optimal
     * @author Jin Lin
     * @created 2019 -06-30 14:12:25
     */
    public void setOptimal(Integer optimal) {
        this.optimal = optimal;
    }
}
